package com.xhwy.controller;

import com.xhwy.entity.Product;
import com.xhwy.entity.ProductImage;
import com.xhwy.param.ProductIdParam;
import com.xhwy.service.ProductImageService;
import com.xhwy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/productImage")
public class ProductImageController {

    @Autowired
    private ProductImageService productImageService;

    @GetMapping("/getByProductId")
    public R getByProductId(@Validated ProductIdParam productIdParam, BindingResult result){
        if(result.hasErrors()){
            return R.fail("参数异常，查询图片失败");
        }
        return productImageService.getByProductId(productIdParam);
    }
}
